<?php
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('data_setting', false);	
my_component_load('yearly_income' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$yearly_income_id  = isset( $_GET['yearly_income_id'] ) ? $_GET['yearly_income_id']:  0;
$yearly_group_id  = isset( $_GET['yearly_group_id'] ) ? $_GET['yearly_group_id']:  0;
$modulname = "Admin _BN_ Yearly Income";
if($_SERVER['REQUEST_METHOD'] == "POST" ):
   	switch($task){
		case   "edit_yearly_income_page" :
			$validatepost = form_yearly_income_validate($id);
			if($validatepost)
			{
				$errors = message_multi_error($validatepost);
				$content = $errors;
				$content .= form_yearly_income_create($id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else {
					form_yearly_income_submit($id);
					$content =  "Updated";
					generate_my_web($content,"","plain.php");
					exit;
				 }
			break; 
		case   "create_yearly_group_page" :
			$validatepost = form_yearly_group_validate($yearly_income_id, $id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_yearly_group_create($yearly_income_id,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_yearly_group_submit($yearly_income_id,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=yearly_income&task=list_yearly_group&yearly_income_id='.$yearly_income_id);
			break;					
		case   "create_komponen_page" :
			$validatepost = form_komponen_validate($yearly_income_id,$yearly_group_id, $id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_komponen_create($yearly_income_id,$yearly_group_id,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_komponen_submit($yearly_income_id,$yearly_group_id,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=yearly_income&task=list_komponen&yearly_income_id='.$yearly_income_id);
			break;				
	}
   

else: 	
	if($task == "edityearly_income"){
		$title= ($id > '0' ) ?  "Perubahan data" : "Tambah data";
		facebox_page('index.php?com=yearly_income&task=edit_yearly_income_page&id='.$id , $title , 210	); 
	}elseif($task == "edit_yearly_income_page"){ 
		$content  = form_yearly_income_create($id);
		generate_my_web($content,"","plain.php");
		exit; 
	}elseif($task == 'delete'){ // DELETE ITEM	
		remove_yearly_income($id);
		my_direct('index.php?com=yearly_income');

	}elseif($task =='list_yearly_group'){	
		$pagename = "Kelompok";
		load_facebox_script();
		$view =  list_yearly_group($yearly_income_id); 
		$href = 'index.php?com=yearly_income&task=create_yearly_group&yearly_income_id='.$yearly_income_id.'&id=0';
	}elseif($task == "create_yearly_group"){ 
		$title= ($id > '0' ) ?  "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=yearly_income&task=create_yearly_group_page&yearly_income_id='.$yearly_income_id.'&id='.$id , $title , 300	);
	}elseif($task == "create_yearly_group_page"){ 
		$content  = form_yearly_group_create($yearly_income_id,$id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task =='yearly_group_delete'){
		 delete_yearly_group($id);
		 my_direct($_SERVER['HTTP_REFERER']);	
		
	}elseif($task =='list_komponen'){	
		$pagename = "Komponen";
		load_facebox_script();
		$view =  list_komponen($yearly_income_id,$yearly_group_id); 
		$href = 'index.php?com=yearly_income&task=create_komponen&yearly_income_id='.$yearly_income_id.'&yearly_group_id='.$yearly_group_id.'&id=0';
	}elseif($task == "create_komponen"){ 
		$title= ($id > '0' ) ?  "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=yearly_income&task=create_komponen_page&yearly_income_id='.$yearly_income_id.'&yearly_group_id='.$yearly_group_id.'&id='.$id , $title , 400	);
	}elseif($task == "create_komponen_page"){ 
		$content  = form_komponen_create($yearly_income_id,$yearly_group_id,$id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task =='komponen_delete'){
		 delete_komponen($id);
		 my_direct($_SERVER['HTTP_REFERER']);	
	}elseif($task == "plaincetak"){
		@ob_end_clean(); 
		echo'<pre>';
		echo print_plain($yearly_income_id);
		exit;		
	}else{
		$pagename = "Daftar Yearly Income";
		load_facebox_script();
		$view =  list_yearly_income(); 
		$href = 'index.php?com=yearly_income&task=edityearly_income' ;
		
	}
endif;  
$content = spliter_browser( $view , $pagename , $href);
generate_my_web($content, $modulname);
?>